package com.ruoyi.system.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class RestTemplateConfig {

//    @Bean
//    public RestTemplate restTemplate() {
//        // 创建一个自定义的HttpComponentsClientHttpRequestFactory
//        HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(createHttpClient());
//        return new RestTemplate(factory);
//    }

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

//    private CloseableHttpClient createHttpClient() {
//        // 配置HttpClient，比如设置超时等
//        return HttpClients.custom()
//                .setConnectTimeout(Duration.ofSeconds(5).toMillis()) // 连接超时
//                .setSocketTimeout(Duration.ofSeconds(5).toMillis())   // 读取超时
//                .build();
//    }
//
}
